import { Controller, Get, Inject, Body,Post, Query } from '@midwayjs/core';
import { Validate } from '@midwayjs/validate';
import { ObjectIdDTO } from '../../dto';
import { DeptCreateDTO,DeptUpdateDTO, DeptIndexDTO } from '../../dto/dept';
import { DeptService } from '../../service/dept.service';

@Controller('system/dept')
export class DeptController {

  @Inject()
  deptService: DeptService;

  @Get('/index')
  @Validate()
  /**
   * 列表 
   * @param role:UserShowDTO
   * @author zengye
   * @date 2023.03.02 09:21
   */
  async index(@Query() params:DeptIndexDTO) {
    return await this.deptService.index(params);
  }

  @Get('/show')
  @Validate()
  /**
   * 查询详情 部门
   * @param role:UserShowDTO
   * @author zengye
   * @date 2023.03.02 00:18
   */
  async show(@Query() role:ObjectIdDTO) {
    return await this.deptService.show(role);
  }

  
  @Post('/create')
  @Validate()
  /**
   * 创建 部门
   * @param role:RoleCreateDTO
   * @author zengye
   * @date 2023.03.01 23:59
   */
  async create(@Body() role:DeptCreateDTO) {
    return await this.deptService.create(role);
  }

  @Post('/update')
  @Validate()
  /**
   * 更新 部门
   * @param user:UserUpdateDTO
   * @author zengye
   * @date 2023.03.01 23:59 
   */
  async update(@Body() role:DeptUpdateDTO) {
    return await this.deptService.update(role);
  }

  @Post('/delete')
  @Validate()
  /**
   * 删除 部门
   * @param user:UserDeleteDTO 
   * @author zengye
   * @date 2023.03.01 23:59
   */
  async delete(@Body() role:ObjectIdDTO) {
    return await this.deptService.delete(role);
  }
}
